package com.yunda.crypt.security.util;

/**
 * Created by Eenie on 2017/8/24.
 * Email: eeniework@gmail.com
 * Des:
 */

public class StringUtils {
    private StringUtils() {
    }

    public static boolean areNotEmpty(String... var0) {
        boolean var1 = false;
        boolean var2 = var1;
        if(var0 != null) {
            if(var0.length == 0) {
                var2 = var1;
            } else {
                int var3 = var0.length;
                int var4 = 0;

                for(var2 = true; var4 < var3; ++var4) {
                    boolean var5;
                    if(isEmpty(var0[var4])) {
                        var5 = false;
                    } else {
                        var5 = true;
                    }

                    var2 &= var5;
                }
            }
        }

        return var2;
    }

    public static byte[] convertBytes(String var0) {
        byte[] var2;
        if(var0 == null) {
            var2 = null;
        } else {
            try {
                var2 = var0.getBytes("UTF-8");
            } catch (Exception var1) {
                throw new RuntimeException(var1);
            }
        }

        return var2;
    }

    public static String convertString(byte[] var0, int var1, int var2) {
        String var4;
        if(var0 == null) {
            var4 = null;
        } else {
            try {
                var4 = new String(var0, var1, var2, "UTF-8");
            } catch (Exception var3) {
                throw new RuntimeException(var3);
            }
        }

        return var4;
    }

    public static boolean isEmpty(String var0) {
        boolean var1 = false;
        boolean var3;
        if(var0 != null) {
            int var2 = var0.length();
            if(var2 != 0) {
                for(int var4 = 0; var4 < var2; ++var4) {
                    var3 = var1;
                    if(!Character.isWhitespace(var0.charAt(var4))) {
                        return var3;
                    }
                }

                var3 = true;
                return var3;
            }
        }

        var3 = true;
        return var3;
    }

    public static boolean isNumeric(Object var0) {
        boolean var1 = false;
        boolean var2;
        if(var0 == null) {
            var2 = var1;
        } else {
            char[] var5 = var0.toString().toCharArray();
            int var3 = var5.length;
            var2 = var1;
            if(var3 >= 1) {
                int var4;
                if(var3 > 1 && var5[0] == 45) {
                    var4 = 1;
                } else {
                    var4 = 0;
                }

                while(true) {
                    if(var4 >= var3) {
                        var2 = true;
                        break;
                    }

                    var2 = var1;
                    if(!Character.isDigit(var5[var4])) {
                        break;
                    }

                    ++var4;
                }
            }
        }

        return var2;
    }

    public static String toUnderlineStyle(String var0) {
        StringBuilder var1 = new StringBuilder();

        for(int var2 = 0; var2 < var0.length(); ++var2) {
            char var3 = var0.charAt(var2);
            if(Character.isUpperCase(var3)) {
                if(var2 > 0) {
                    var1.append("_");
                }

                var1.append(Character.toLowerCase(var3));
            } else {
                var1.append(var3);
            }
        }

        return var1.toString();
    }

    public static String unicodeToChinese(String var0) {
        StringBuilder var1 = new StringBuilder();
        if(!isEmpty(var0)) {
            for(int var2 = 0; var2 < var0.length(); ++var2) {
                var1.append(var0.charAt(var2));
            }
        }

        return var1.toString();
    }
}
